%define with_tests 1
{% set pypi_name = 'ovsdbapp' %}
{% set upstream_version = upstream_version('1.8.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        A library for creating OVSDB applications
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('netaddr') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('ovs') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
The ovdsbapp library is useful for creating applications that communicate via
Open_vSwitchs OVSDB protocol (https://tools.ietf.org/html/rfc7047). It wraps
the Python 'ovs' and adds an event loop and friendly transactions.

%package -n {{ py2name(py_versions='py3') }}
Summary:        A library for creating OVSDB applications
Requires:       {{ py3('fixtures') }}
Requires:       {{ py3('netaddr') }}
Requires:       {{ py3('ovs') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('six') }}

%description -n {{ py2name(py_versions='py3') }}
The ovdsbapp library is useful for creating applications that communicate via
Open_vSwitchs OVSDB protocol (https://tools.ietf.org/html/rfc7047). It wraps
the Python 'ovs' and adds an event loop and friendly transactions.

%package -n python-ovsdbapp-doc
Summary:        Documentation for OpenStack log library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n python-ovsdbapp-doc
Documentation for the ovsdbap library.

%prep
%autosetup -p1 -n {{pypi_name }}-%{version}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION={{ upstream_version }} PYTHONPATH=. \
    %sphinx_build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%if 0%{?with_tests}
%check
OS_TEST_PATH=./ovsdbapp/tests/unit PYTHONPATH=. python3 -m stestr.cli run
%endif

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/ovsdbapp
%{python3_sitelib}/*.egg-info

%files -n python-ovsdbapp-doc
%license LICENSE
%doc doc/build/html

%changelog
